package com.example.mapper;

import com.example.annotation.PublicAutoFill;
import com.example.enumeration.OperationType;
import com.github.pagehelper.Page;
import com.pojo.dto.QueryPageDTO;
import com.pojo.entity.Employee;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmployeeMapper {

    @PublicAutoFill(OperationType.INSERT)
    @Insert("insert into employee(name,username,password,phone,sex," +
            "id_number,status,create_time,update_time,create_user,update_user)" +
            " values(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime}," +
            "#{updateTime},#{createUser},#{updateUser})")
    void save(Employee employee);

    @Select("select * from employee where username = #{username}")
    Employee getByUsername(@Param("username") String username);

    @Select("select * from employee")
    List<Map<String, Object>> allList();


    Page<Employee> queryPage(QueryPageDTO queryPageDTO);

    @Select("select * from employee where id = #{id}")
    Employee getById(@Param("id") Long id);

    @PublicAutoFill(OperationType.UPDATE)
    void update(Employee employee);

    @Delete("delete from employee where id = #{id}")
    void deleteById(Long id);
}
